/*
Unplugged: A library for creating plugins.
    Copyright (C) 2011  Daniel Gutson, FuDePAN

    Unplugged is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Unplugged is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Unplugged.  If not, see <http://www.gnu.org/licenses/>.

    This is an example framework file.
*/

#include <stdlib.h>
#include <iostream>
#include "unplugged/framework.h"
#include "framework_example.h"

int main()
{
    try
    {
        SampleFramework::Framework framework;
        //TODO: command line
        std::string file = "install/libs/libunplugged-example-plugin.so";
        framework.loadPlugin(Unplugged::load_plugin<SampleFramework::BasePlugin>(file));
        return EXIT_SUCCESS;
    }
    catch (const std::exception& e)
    {
        std::cerr << "Error: " << e.what() << std::endl;
        return EXIT_FAILURE;
    }
}

// --------------------------------
namespace SampleFramework
{
Framework::Framework() :
    bp(NULL)
{}

Framework::~Framework()
{
    //delete bp;
    if (bp != NULL)
    {
        bp->unload();
    }
}

void Framework::loadPlugin(BasePlugin* plugin)
{
    bp = plugin;
    bp->speak();
}
}

